<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="/common/taglibs.jsp"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
	<title>当前站点首页生成</title>
	<%@ include file="/common/meta.jsp"%>
	<%@ include file="/common/common.jsp"%>
</head>
<body>
<s:set name="siteId" value="#session['CURRENT_SITE'].siteId"></s:set>
	<div class="curmb"><s:text name="your.site.position"/>:<a href="${ctx}/main.action"><s:text name="homepage"/></a><span>></span>当前站点首页生成</div>
	<div class="listtit"></div>

	 <table class="addgrid">
			<tr>
				<th>首页模板:</th>
				<td><s:textfield type="text" name="site.siteName" id="index_siteName" cssClass="txtin" readonly="readonly"/></td>
			</tr>
			<tr>
				<th>首页模板:</th>
				<td><s:textfield  type="text" name="site.siteIndexTpl" id="index_tpl" cssClass="txtin" readonly="readonly"/>
					<!-- <input type="button"  id="index_tpl_select" class="btnlist2" value="模板选择"/> -->
				</td>
			</tr>
			<tr>
				<th>&#160;
				   <s:if test="%{authLicence('2_2_1',#siteId)}"><a href=''>dhs</a></s:if>
				   <s:else>diss</s:else>
				   
				   <s:property value="#siteId"/>
				</th>
				<td>
					<input type="button"  id="index_preview" class="btnlist2" value="预览"/>
					<input type="button"  id="index_generate" class="btnlist2" value="生成"/>					
				</td>
			</tr>
	 </table>		
   <div id="error_div">
   </div>
	 
</body>
</html>
<script type="text/javascript">
	$(function(){
		$("#index_preview").click(preview);
		$("#index_generate").click(generate);
	});


	
	function preview(){
		var url = "${ctx}/genarate/index-preview.action";
		window.open(url);	
	}
	
	function generate(){
		$.ajax({
			url:"${ctx}/genarate/index-generate.action?t="+new Date().getTime() ,
			type:"get",
			dataType:"text", 
			success:function(data){
				try {
					var json = eval('('+data +')');
					if(json.flag){
						alert(json.msg);
						$("#error_div").html("<a href="+json.path+" target='_blank'>\u9759\u6001\u9884\u89c8</a> ");
						 
					} 					
				} catch (e) {
					 $("#error_div").html(data);
				}
			},
			error:function(){
				alert("\u51fa\u9519\u4e86");
			}	
		});
	}
</script>